<?php
echo $javascript->link(array('autocomplete/jquery.tokeninput'));
echo $this->Html->css(array('autocomplete/token-input-facebook', 'autocomplete/token-input'));
if(isset($this->params['named']['status'])){$this->passedArgs['status']=$this->params['named']['status'];
 $this->Paginator->options(array('url' => $this->passedArgs));
 //debug($Subjects);
}
?>
<!-----Print screen Javascript---->

<script language="javascript">
    function Print()
    {
        document.print.submit();
        document.getElementById('printbutton').style.display='none';
        window.print();
    }

    

</script>
<!-- Print Screen Javascript ends--->

<?php
//echo $javascript->link(array('popup/jquery.fancybox-1.3.4.pack', 'popup/fancybox.impl'));
//echo $this->Html->css(array('jquery.fancybox-1.3.4'), 'stylesheet', array('media' => 'screen'));

?>

<table width="1024px">
    <tr>
        <td>
            <div>
                <div style="float: left">
                    <div style="float: left">
                        <?php
                        echo $this->Form->Create('Subject', array('controller' => 'Subjects', 'action' => 'search'));
                        echo $this->Form->input('search', array('label' => '', 'value' => 'Search By subject or title', 'id' => 'autocomplete', 'class' => 'watermark', 'onclick' => 'this.value=""', 'AUTOCOMPLETE' => 'OFF'));
                        ?>
                   
                    <div style="float: right; margin: 2px 0 0 164px;">
                       <?php echo $this->Form->end(array('label'=>'Search','class'=>'mybutton'));?>
                        <?php if($_SERVER['HTTP_HOST']=='localhost'){$url='/ratetheu/admin/Subjects/search_suggestion';}else{$url='search_suggestion';} ?>
                        <script type="text/javascript">
                            $(document).ready(function() {
                                $("#autocomplete").tokenInput("<?php echo $this->base; ?>/admin/Subjects/search_suggestion", {
                                    theme: "facebook",
                                    tokenLimit: 1,
                                    preventDuplicates: true
                                });
                            });
                        </script>
                    </div>
                         </div>
                </div>
                <div  style="float:right">


                    <?php
                    if(!$access->check('User')){
                    echo $this->Html->link(
                            $this->Html->image('../img/add_more.png', array('alt' => 'Add more')), array('action' => 'add'), array('escape' => false, 'class' => 'noprint')
                    );
                    }?></div>
            </div>
        </td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
        <td>

            <table width="100%" id="table" >
                <tr >
                    <th width="30px"><?php echo $this->Paginator->sort('ID', 'id'); ?></th>
                    <th width="224px"><?php echo $this->Paginator->sort('Subject', 'subject'); ?></th>
                    <th width="250px"><?php echo "Adjectives"; ?></th>
                    <th width="250px"><?php echo "Tags"; ?></th>
                    <th width="150px"><?php echo "17 + ?"; ?></th>
                    <th width="150px"><?php echo "Status"; ?></th>
                    <th width="40px">View</th>
                    <th width="40px">Edit</th>
                    <?php if($this->Access->check('Subject', 'delete')){ ?><th width="40px">Delete</th><?php }?>

                </tr>
                <?php foreach ($Subjects as $data): ?>
                    <tr id="table_content">
                        <td><?php echo $data['Subject']['id']; ?></td>
                        <td><?php
                if (!empty($data['Subject']['desc'])) {
                    $attribute = " <span style='padding-left:6px;'>(" . $data['Subject']['desc'] . ")</span>";
                } else {
                    $attribute = '';
                } echo Inflector::humanize($data['Subject']['subject']);
                ?></td>
                        <td><?php echo $data['Subject']['adjective_ids']; ?></td>
                        <td><?php echo $data['Subject']['tag_ids']; ?></td>
                        <td><?php
                        if ($data['Subject']['17+'] == '0') {
                            echo "No";
                        } else {
                            echo "Yes";
                        }
                    ?></td>
                        <td>
                            <?php if($access->check('Adjective')){
                            if ($data['Subject']['status'] == '0') {
                                echo $this->Html->link($this->Html->image('status' . $data['Subject']['status'] . '.png', array('alt' => 'View', 'border' => '0','title'=>'Click to Approve.')), array('action' => 'admin_approve', $data['Subject']['id']), array('escape' => false));
                            } else {
                                echo $this->Html->image('status' . $data['Subject']['status'] . '.png', array('alt' => 'View', 'border' => '0'));
                            }
                            }else{
                                if ($data['Subject']['status'] == '0') {
                                echo $this->Html->image('status' . $data['Subject']['status'] . '.png', array('alt' => 'View', 'border'=> '0','title'=>'New'));
                            } else {
                                echo $this->Html->image('status' . $data['Subject']['status'] . '.png', array('alt' => 'View', 'border' => '0'));
                            }
                            }
                            ?>
                        </td>
                        <td><?php echo $this->Html->link($this->Html->image('view.png', array('alt' => 'View', 'border' => '0','title'=>'Click to View subject')), array('action' => 'admin_view', $data['Subject']['id']), array('escape' => false)); ?></td>
                        <td><?php if(($this->Access->check('User', 'read')) || ($data['Subject']['user_id']==$_SESSION['Auth']['User']['id'] && $data['Subject']['status']=='0')){ echo $this->Html->link($this->Html->image('user_edit.png', array('alt' => 'Edit', 'border' => '0')), array('action' => 'admin_edit', $data['Subject']['id']), array('escape' => false)); } ?></td>
                        <td><?php  if($this->Access->check('Subject', 'delete')) echo $this->Html->link($this->Html->image('trash.png', array('alt' => 'Delete', 'border' => '0')), array('action' => 'admin_delete', $data['Subject']['id'],'status'=>@$this->params['named']['status']), array('escape' => false, 'onclick' => "return confirm('Are you sure you want to delete?')")); ?></td>
                    </tr>
                        <?php endforeach; ?>
                <tr><td colspan="9"><?php          

echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled'));?>
                       
                        <?php
 echo $this->Paginator->numbers(); 
 ?>
                        
                        <?php
echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); 

 echo $this->Paginator->counter();     
                
                        ?></td></tr>
            </table>
        </td>
    </tr>
</table>
<!--- ***********************************   This will be used to print screen        *************************************/--->

<div style="margin-top:31px; margin-left:3px;">
    <form name="print" method="POST" action="">
        <input type="submit" id="printbutton" name="print" value="Print" style="width:60px; height:30px;" onclick="Print();" />
    </form>
</div>	
<!---************************************************************************/--->	


<script type="text/javascript">
    $(document).ready(function() {
        /*
         *   Examples - images
         */

			
        $("a#example3").fancybox({
            'transitionIn'	: 'none',
            'transitionOut'	: 'none'	
        });
    });
    $(".watermark").click(function(){
        $(this).removeClass()});
</script>
